/**
 * 
 */
package org.dragonfire.util;

import java.lang.reflect.Array;
import java.util.ArrayList;


/**
 * @author Darth Android
 * @date Jul 12, 2007
 */
public class DArray {
	
	public static <T> T[] subArray(T[] array, int start, int end) {
		if (array==null || start < 0 || end > array.length || end < start)
			throw new IllegalArgumentException("array is null or start/end are out of bounds.");
		ArrayList<T> ret = new ArrayList<T>();
		int count = 0;
		for (int i = start; i < end; i++) {
			ret.add(array[i]);
		}
		return ret.toArray((T[])Array.newInstance(array.getClass().getComponentType(), ret.size()));
	}

}
